﻿/*
 * http://www.graficaobscura.com/matrix/index.html
 * */
package fab.graphics 
{
	import flash.filters.ColorMatrixFilter;
	/**
	 * ...
	 * @author fab
	 */
	public class ColorMatrixFilterParam extends ColorMatrixFilter
	{
		
		public function ColorMatrixFilterParam() 
		{
			
		}
		public function saturation() 
		{
			
		
		
		/*
		To convert a color image into a black and white image, this matrix is used:
    float mat[4][4] = {
        rwgt,   rwgt,   rwgt,   0.0,
        gwgt,   gwgt,   gwgt,   0.0,
        bwgt,   bwgt,   bwgt,   0.0,
        0.0,    0.0,    0.0,    1.0,
    };
Where rwgt is 0.3086, gwgt is 0.6094, and bwgt is 0.0820. This is the luminance vector. Notice here that we do not use the standard NTSC weights of 0.299, 0.587, and 0.114. The NTSC weights are only applicable to RGB colors in a gamma 2.2 color space. For linear RGB colors the values above are better.
In effect, this calculates:

	tr = r*rwgt + g*gwgt + b*bwgt;
	tg = r*rwgt + g*gwgt + b*bwgt;
	tb = r*rwgt + g*gwgt + b*bwgt;
Modifying Saturation

To saturate RGB colors, this matrix is used:
     float mat[4][4] = {
        a,      b,      c,      0.0,
        d,      e,      f,      0.0,
        g,      h,      i,      0.0,
        0.0,    0.0,    0.0,    1.0,
    };
Where the constants are derived from the saturation value s as shown below:
    a = (1.0-s)*rwgt + s;
    b = (1.0-s)*rwgt;
    c = (1.0-s)*rwgt;
    d = (1.0-s)*gwgt;
    e = (1.0-s)*gwgt + s;
    f = (1.0-s)*gwgt;
    g = (1.0-s)*bwgt;
    h = (1.0-s)*bwgt;
    i = (1.0-s)*bwgt + s;
One nice property of this saturation matrix is that the luminance of input RGB colors is maintained. This matrix can also be used to complement the colors in an image by specifying a saturation value of -1.0.
Notice that when s is set to 0.0, the matrix is exactly the "convert to luminance" matrix described above. When s is set to 1.0 the matrix becomes the identity. All saturation matrices can be derived by interpolating between or extrapolating beyond these two matrices.

This is discussed in more detail in the note on Image Processing By Interpolation and Extrapolation.

Applying Offsets to 
*/
		}

	}

}